package com.lots.mapper;

import com.lots.domain.dto.DishUploadDto;
import com.lots.domain.entity.Dish;
import com.lots.domain.entity.DishCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
    @Select("select * from dish order by star desc , create_time asc")
    List<Dish> getDishList();
    //查询菜品类别
    @Select("select * from dish_category ")
    List<DishCategory> getDishCategories();

    @Select("select * from dish where categorie_id = #{id} order by star desc , create_time asc")
    List<Dish> getDishByCategoryId(Integer id);

    @Select("select * from dish where create_time >= #{start} and create_time <= #{end} order by star desc limit 10")
    List<Dish> getMathTopDish(String start, String end);

    @Select("select * from dish order by star desc limit 10")
    List<Dish> getTopDish();

    //根据id批量查询
    List<Dish> queryStars(List<Long> favoriteList);
    @Update("update dish set star =star + #{i} where id = #{dishId}")
    void updateStar(Long dishId, int i);

    void upload(Dish dish);

    List<Dish> queryByIds(List<Long> dishIds);

    @Select("select * from dish where categorie_id = #{id} order by  create_time desc limit 9")
    List<Dish> getDishByCategoryIdTop(Integer id);
}
